//
//  KLGoodTableViewCell.m
//  KunLun
//
//  Created by Mac on 2017/11/27.
//  Copyright © 2017年 stoneobs@icloud.com. All rights reserved.
//

#import "KLGoodTableViewCell.h"

@interface KLGoodTableViewCell()
@property(nonatomic, strong) UIImageView                      *iconImageView;
@property(nonatomic, strong) STLabel                            *titleLable;
@property(nonatomic, strong) STLabel                            *desLable;//描述

@property(nonatomic, strong) STLabel                            *numLbale;//售出多少盒库存多少
@end
@implementation KLGoodTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self ==[super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self configSubView];
    }
    return self;
}
+ (CGFloat)cellHeight{
    return 125;
}
#pragma mark --subView
- (void)configSubView{
    
    self.backgroundColor = [UIColor whiteColor];
    
    self.iconImageView = [[UIImageView alloc] initWithFrame:CGRectMake(15, 10, 100, 100)];
    self.iconImageView.image = [UIImage imageNamed:@"12"];
    [self addSubview:self.iconImageView];
    
    self.titleLable = [[STLabel alloc] initWithFrame:CGRectMake(self.iconImageView.right + 10, self.iconImageView.top + 5, UIScreenWidth - self.iconImageView.right - 20, 20)
                                                text:@"北京红烧饭大酒店"
                                           textColor:KL_firstTextColor
                                                font:15
                                         isSizetoFit:NO
                                       textAlignment:NSTextAlignmentLeft];
    [self addSubview:self.titleLable];
    
    self.desLable = [[STLabel alloc] initWithFrame:CGRectMake(self.iconImageView.right + 10, self.titleLable.bottom +3, UIScreenWidth - self.iconImageView.right - 20, 40)
                                              text:@"dasdasdas三大范德萨范德萨都是范德萨范德萨佛挡杀佛 是的范德萨"
                                         textColor:KL_secendTextColor
                                              font:14
                                       isSizetoFit:NO
                                     textAlignment:NSTextAlignmentLeft];
    [self addSubview:self.desLable];
    
    self.moneyLable = [[STLabel alloc] initWithFrame:CGRectMake(self.iconImageView.right + 10, self.desLable.bottom + 3, UIScreenWidth - self.iconImageView.right - 20, 20)
                                                text:@"$455  原价:$755"
                                           textColor:KL_redColor
                                                font:14
                                         isSizetoFit:NO
                                       textAlignment:NSTextAlignmentLeft];
    NSDictionary *attribtDic = @{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle],NSForegroundColorAttributeName:KL_secendTextColor};
    self.moneyLable.attributedText = [self.moneyLable.text st_convertAttributeStringWithKeyWord:@"原价:$755" attributes:attribtDic];
    [self addSubview:self.moneyLable];
    
    
    self.numLbale = [[STLabel alloc] initWithFrame:CGRectMake(self.iconImageView.right + 10, self.moneyLable.bottom + 3, UIScreenWidth - self.iconImageView.right - 20, 20)
                                                   text:@"已售出：234 库存：999"
                                              textColor:KL_secendTextColor
                                                   font:14
                                            isSizetoFit:NO
                                          textAlignment:NSTextAlignmentRight];
    self.numLbale.right = UIScreenWidth - 10;
    [self addSubview:self.numLbale];
}
- (void)setGoodModel:(KLGoodModel *)goodModel{
    _goodModel = goodModel;
    
    self.titleLable.text = goodModel.goods_name;
    self.desLable.text = goodModel.abstract;
    
    self.moneyLable.text = [NSString stringWithFormat:@"￥%@",goodModel.price];
    if (goodModel.discount_price.length) {
        self.moneyLable.text = [NSString stringWithFormat:@"￥%@",goodModel.discount_price];
    }
    self.numLbale.text =  [NSString stringWithFormat:@"已售出:%@    库存:%@",
                           goodModel.sell_num.description,
                           goodModel.stock.description];
    [self.iconImageView sd_setImageWithURL:[NSURL URLWithString:goodModel.exhibition_map]];
}

@end
